package com.javaee.tallybook.service;

import com.javaee.tallybook.mapper.TallyMapper;
import com.javaee.tallybook.pojo.Tally;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("tallyService")
public class TallyService {

    @Autowired
    private TallyMapper tallyMapper;

    public List<Tally> getList(String name){
        return tallyMapper.selectListByName(name);
    }

    public Integer addList(Tally tally) {
        return tallyMapper.insertList(tally);
    }

    public Integer delList(Integer id) {
        return tallyMapper.deleteList(id);
    }

    public Double countIn(String name){
        String type="收入";
        return tallyMapper.countIn(type,name);
    }
    public Double countOut(String name){
        String type="支出";
        return tallyMapper.countOut(type,name);
    }

    public Integer update(Tally tally) {
        return tallyMapper.updateList(tally);
    }
}
